<!DOCTYPE html>
<html>
<head>
	<include file="Public:common-css" />
	<link type="text/css" rel="stylesheet" href="__ICSS__/orderpay.css" />
	<script>window.history.forward();</script>
</head>
<body>
<div class="container">
<!-------------------------header--------------------------------->
<include file="Public:header" />
<!--------------------------content------------------------------->
    <div class="content">
    	<input type="hidden" id="orderCode" value="<{$info.code}>"/>
    	<input type="hidden" id="totalPrice" value="<{:formatPrice($info['real_price'] + $info['mail_fee'])}>"/>
    	<input type="hidden" id="balance" value="<{$balance}>"/>
   		<div class="wrap car-order-info">
		    <div class="garnishtip-box">
		    	<p>订单编号：<{$info.code}></p>
		    	<strong>实付款：<font class="org pay-price">¥<{:formatPrice($info['real_price'] + $info['mail_fee'])}></font></strong>
		    </div>
	    </div>
	    <div class="wrap garnishtip-box-bottom"></div>
    	<div class="wrap order-info">
	    	<table width="100%" border="0" class="order-table">
		   		<thead>
		   			<tr>
						<td height="40" colspan="4" align="left" valign="middle"><span style="padding-left:25px; font-size:18px;">选择支付方式</span></td>
				  	</tr>
		   		</thead>
			</table>
			<div class="pay-mode-box">
				<div class="order-pay-box order-payment-list">
					<ul>
						<li ref="1" class="on">
							<i class="pay-icon pay-icon-balance"></i><span>余额支付</span><em>账户余额：<font>¥<{$balance}></font></em><a href="__ROOT__/User/recharge" target="_blank" class="recharge-btn">充值享优惠</a>
							<div class="select-icon"></div>
						</li>
						<li ref="2">
							<i class="pay-icon pay-icon-zfb"></i><span>支付宝支付</span>
							<div class="select-icon"></div>
						</li>
						<!-- 
						<li ref="3">
							<i class="pay-icon pay-icon-wx"></i><span>微信支付</span>
							<div class="select-icon"></div>
						</li> 
						-->
					</ul>
				</div>
				<button class="order-pay-btn" id="payment-btn">支付</button>
				<div class="clearfix"></div>
			</div>
	    </div>
    </div>
    <div class="clr"></div>
<!--------------------------content-end--------------------------->
    <include file="Public:footer" />
</div>

</body>
<include file="Public:common-js" />
<script type="text/javascript">
$(function() {
	
	$(".order-payment-list").find("li").click(function() {
		$(".order-payment-list").find("li").removeClass("on");
		$(this).addClass("on");
		if($(".order-payment-list").find(".on").attr("ref") == "1") {
			$("#payment-btn").attr("href","javascript:void(0)");
			$("#payment-btn").removeAttr("target");
		}
	})
	//充值
	$(".recharge-btn").click(function() {
		layer.open({
		    type: 1,
		    closeBtn: false,
		    title: false,
		    area: ['460px', '220px'],
		    content:'<div class="payment-tip-box"><strong>请在打开的页面上完成充值</strong><p>充值完成前请勿关闭此窗口，完成充值后根据您的情况进行操作</p><a class="pay-success-btn" href="javascript:void(0)" onclick="refreshPage()">已完成充值</a></div>'
		});
	})
	//支付
	$("#payment-btn").click(function() {
		if($(".order-payment-list").find(".on").attr("ref") == "1") {//余额支付
			var balance = parseFloat($("#balance").val());
			var totalPrice = parseFloat($("#totalPrice").val());
			if(totalPrice > balance){
				layer.msg("余额不足，现在充值可享充值返利，千万别错过！");
				return false;
			}
			layer.confirm("确定支付？",{
				  btn: ['确认','取消'] 
			}, function(){
				$.ajax({
					url:"__ROOT__/Pay/balancePayOrder",
					type:"post",
					data:{'orderCode':$("#orderCode").val()},
					success:function(data){
						var data = eval("("+data+")");
						if(data.status == 1){
							layer.msg(data.info);
							window.location.href = "__ROOT__/Order/index";
						}else{
							layer.msg(data.info);
						}
					}
				})
			})
		}else if($(".order-payment-list").find(".on").attr("ref") == "2") {//支付宝支付
			layer.open({
			    type: 1,
			    closeBtn: false,
			    title: false,
			    area: ['460px', '220px'],
			    content:'<div class="payment-tip-box"><strong>请在打开的页面上完成付款</strong><p>支付完成前请勿关闭此窗口，完成支付后根据您的情况进行操作</p><a class="pay-success-btn" href="__ROOT__/Order">已完成支付</a></div>'
			});
			window.open("__ROOT__/Alipay/alipayPayOrder/orderCode/"+$("#orderCode").val());
		}else if($(".order-payment-list").find(".on").attr("ref") == "3"){//微信支付
			layer.msg("微信支付");
		}
	})
})
function refreshPage() {
	window.location.reload();
}
</script>

</html>
